<%@ page import = "java.util.*, org.rescue.search.Dataset, org.rescue.search.Document" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<jsp:include page="header.jsp">
	<jsp:param name="activetoolbar" value="find" />
</jsp:include>

    <div id="textResultsInfoBar" >
    	<%if(session.getAttribute("dataset") != null) {
            out.print("Found 10 of 10 results requested for: (" + session.getAttribute("query") + ")");
			out.print("<div id='textResultsToolBar'>");
			out.print("<form name='saveform' method='post' action='SaveDataset.do' id='saveform'>");
	        out.print("<button name='action' value='save' type='submit'><img border='0' src='images/icon-save.png' alt='Save' /></button>");
            out.print("</form>");
            out.print("</div>");
		}
		%>
	</div>
	
	

    <!-- RESULTS AREA -->
    <div id="textResults" >


		<!-- RESULTS BY RELEVANCE -->		
		<c:if test="${param.sort == 'relevance' || empty param.sort }" >			
	        <ul style="list-style: none; padding: 0; margin: 0;">
	            <li></li>
				<c:if test="${!empty dataset}"> 
					<jsp:useBean id="dataset" class="org.rescue.search.Dataset" scope="session" />
					<c:forEach var="document" items="${dataset.documents}" >
						<li style='list-style: none;  text-decoration: underline; font-size: 14px; font-family: sans-serif;'><a href='${document.URL}'>${document.title}</a></li>
						<li style='list-style: none; padding-bottom: 0.35em;  font-size: 12px; font-family: sans-serif; color: green'>${document.URL}</li>
					</c:forEach>
				</c:if>
	        </ul> 
        </c:if>
               
        
        <!-- RESULTS BY LOCATION (MAP DISPLAY) -->
		<c:if test="${param.sort == 'location'}" >
    		<div id="map" style="width: 600px; height: 400px; z-index: 118; left: 0px; position: absolute; top: 0px; "></div>
    		
    		<noscript><b>JavaScript is currently disabled in your browser.</b> JavaScript must be enabled in your browser for you to view map analysis results.  </noscript>
    		
	    	<script type="text/javascript">
    			//<![CDATA[

    			var map;

			    if (GBrowserIsCompatible()) {
    
      				var analysis_tile_layer = new GTileLayer(new GCopyrightCollection(), 0, 17);
      				analysis_tile_layer.getTileUrl = function(a,b) {
        				b=this.maxResolution()-b;
        				return "http://maps.google.com/mapsdt?id=http://128.195.185.173:8080/miner/GenerateKML.do?locationIds=<%= session.getAttribute("locations") %>&x="+a.x+"&y="+a.y+"&zoom="+b;
							
        				
      				};    
    
      				// arrays to hold copies of the markers
      				var gmarkers = [];
      				var htmls = [];
      				var i = 0;

      				// A function to create the marker and set up the event window
      				function createMarker(point,name,html,icon) {
	        			var marker = new GMarker(point,gicons[icon]);
	        			GEvent.addListener(marker, "click", function() {
	          				marker.openInfoWindowHtml(html);
	        			});       
	        			gmarkers[i] = marker;
	        			htmls[i] = html;
				        i++;
				        return marker;
		    	   	}

			      	// This function picks up the click and opens the corresponding info window
			      	function myclick(i) {
			      		gmarkers[i].openInfoWindowHtml(htmls[i]);
	      			}

			        // create the map
			        map = new GMap2(document.getElementById("map"));
			        map.addControl(new GLargeMapControl());
			        map.addControl(new GMapTypeControl());
			        map.setCenter(new GLatLng( 33.64320131629904,-117.84120619297028), 4, G_HYBRID_MAP);
				    map.addOverlay( new GTileLayerOverlay(analysis_tile_layer) );
	    		}
	
	    		else {
	      			alert("Sorry, the Google Maps API is not compatible with this browser");
	    		}
	    		//]]>
	    	</script>   		
		</c:if>

		                                
    </div>

            
    <div id="toolbar">
        Sort gems by:
        <ul id="toolbarlist">
            <li <c:if test="${param.sort == 'relevance' || empty param.sort }" >id="current"</c:if> ><a href="search.jsp?sort=relevance">relevance</a></li>
            <li <c:if test="${param.sort == 'topic'}" >id="current"</c:if> ><a href="search.jsp?sort=topic">topic</a></li>
            <li <c:if test="${param.sort == 'location'}" >id="current"</c:if> ><a href="search.jsp?sort=location">location</a></li>
            <li <c:if test="${param.sort == 'time'}" >id="current"</c:if> ><a href="search.jsp?sort=time">time</a></li>       
        </ul>
        
        Related topics:
        <ul>
            <li>topic A</li>
            <li>topic B</li>
            <li>topic C</li>
            <li>topic D</li>        
        </ul>
        
    </div>
    
    
    <!--<a href="#">Next 10 Results</a>-->

    <!-- FACETS -->
    <!-- <div id="facetsResults" style="width: 175px; height: 450px ; z-index: 121; left: 25px; position: absolute; top: 235px;"><br /><div style="font-family: sans-serif; font-size: 14px; color: #9C0000">Broaden Search</div><ul style="list-style: none; padding: 0; margin: 0;"><li style="list-style: none;  font-size: 12px; font-family: sans-serif;"><a href="#">humanitarian aid</a></li><li style="list-style: none;  font-size: 12px; font-family: sans-serif;"><a href="#">hurricane</a></li></ul><br /><div style="font-family: sans-serif; font-size: 14px; color: #9C0000">Related Concepts</div><ul style="list-style: none; padding: 0; margin: 0;"><li style="list-style: none;  font-size: 12px; font-family: sans-serif;"><a href="#">sheltering facility</a></li><li style="list-style: none;  font-size: 12px; font-family: sans-serif;"><a href="#">New Orleans</a></li><li style="list-style: none;  font-size: 12px; font-family: sans-serif;"><a href="#">hurricane relief</a></li><li style="list-style: none;  font-size: 12px; font-family: sans-serif;"><a href="#">FEMA</a></li><li style="list-style: none;  font-size: 12px; font-family: sans-serif;"><a href="#">disaster planning</a></li><li style="list-style: none;  font-size: 12px; font-family: sans-serif;"><a href="#">American Red Cross</a></li></ul></div>    -->



    <!-- MAP DISPLAY -->
    <!--<span id="MapLabel" style="font-family:Arial;font-size:10pt;font-weight:bold;z-index: 122; left: 424px; position: absolute; top: 750px">Results Geographical Distribution:</span>
    <div id="map" style="width: 400px; height: 400px; z-index: 119; left: 425px; position: absolute; top: 770px; "></div>-->
    
    
    <!-- TIMELINE DISPLAY -->
    <!--<span id="TimelineLabel" style="font-family:Arial;font-size:10pt;font-weight:bold;z-index: 116; left: 12px; position: absolute; top: 750px">Results Timeline:</span>    
    <div id="timeline" style="height: 400px; width: 400px; border: 1px solid #aaa; z-index: 120; left: 0 px; position: absolute; top: 770px;"></div>       
    <p />
    <div id="min-date" style="position: absolute; top: 1135px; z-index: 117;"></div>-->
        



<jsp:include page="footer.jsp" />